package cn.xllyd.web.controller;

import cn.xllyd.doc.OrderDoc;
import cn.xllyd.dto.OrderSearchDto;
import cn.xllyd.result.JSONResult;
import cn.xllyd.result.PageList;
import cn.xllyd.service.IOrderEsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("order-es")
@Slf4j
public class OederEsController {
    @Autowired
    private IOrderEsService orderEsService;

    /**
     * es查询订单
     * @param orderDoc
     * @return
     */
    @RequestMapping(value = "/onLineCourse",method = RequestMethod.POST)
    public JSONResult onLineCourse(@RequestBody OrderDoc orderDoc){
        orderEsService.onLineOrder(orderDoc);
        return JSONResult.success();
    }

    /**
     * es搜索高亮聚合
     * @param orderSearchDto
     * @return
     */
    @RequestMapping(value = "/search",method = RequestMethod.POST)
    public JSONResult search(@RequestBody OrderSearchDto orderSearchDto){
        PageList<OrderSearchDto> pageList = orderEsService.search(orderSearchDto);
        return JSONResult.success(pageList);
    }
}
